package com.heima.wemedia.controller.v1;

import com.heima.model.common.dtos.ResponseResult;
import com.heima.model.wemedia.dtos.ChannelDto;
import com.heima.model.wemedia.dtos.WmNewsDto;
import com.heima.model.wemedia.pojos.WmChannel;
import com.heima.wemedia.service.WmChannelService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@Slf4j
@RestController
@RequestMapping("/api/v1/channel")
public class WmChannelController {
    @Autowired
    private WmChannelService wmChannelService;

    /**
     * 频道列表
     * */
    @GetMapping("/channels")
    public ResponseResult channels(){
        return wmChannelService.channels();
    }

    /*
    * 删除频道
    * */
    @GetMapping("/del/{id}")
    public ResponseResult delete(@PathVariable Integer id){
        return wmChannelService.delete(id);
    }

    /*
    * 频道名称模糊分页查询
    * */
    @PostMapping("/list")
    public ResponseResult list(@RequestBody ChannelDto dto){
        return wmChannelService.lists(dto);
    }

    /*
    * 保存频道
    * */
    @PostMapping("/save")
    public ResponseResult save(@RequestBody WmChannel wmChannel){
        return wmChannelService.saves(wmChannel);
    }

    /*
    *修改频道
    * */
    @PostMapping("/update")
    public ResponseResult update(@RequestBody WmChannel wmChannel){
        return wmChannelService.updates(wmChannel);
    }
}
